<template>
    <div class="tableList">
        <el-table :data="tableData" border style="width: 100%;"
            :header-cell-style="{background:'#fafafa',color:'#000',fontWeight:400,fontSize:'12px'}"
            :cell-style="{color:'#5a5a5a',fontSize:'12px',fontWeight:400}" v-loading="loading"
            element-loading-text="加载中" element-loading-background="rgba(250, 250, 250, 0.5)"
            element-loading-spinner="el-icon-loading" ref="tabList">
            <el-table-column label="序号" width="80">
                <template slot-scope="scope">
                    <span>{{(searchForm.page - 1) * (searchForm.limit) + scope.$index + 1}}</span>
                </template>
            </el-table-column>
            <el-table-column label="日期" prop="date" show-overflow-tooltip min-width="180">
               
            </el-table-column>
            <el-table-column label="设备" prop="deviceName" show-overflow-tooltip min-width="180">
              
            </el-table-column>
            <el-table-column label="合计" prop="totalNum" >
              
            </el-table-column>
            <el-table-column label="UPH" prop="uph" >
              
            </el-table-column>

            <el-table-column :label="i + ''" v-for="(i,index) in fullTimeColumnList" :key="index">
                <template slot-scope="scope"> {{ scope.row.timeCountMap[i] }}  </template>
            </el-table-column>
            <div slot="empty">
                <el-empty :image-size="100"></el-empty>
            </div>
        </el-table>
        <el-pagination v-if="total" @size-change="handleSizeChange" @current-change="handleCurrentChange"
            :page-sizes="[10,20,50,100]" :page-size="searchForm.limit" layout="total,prev, pager, next,sizes"
            :total="total" background>
        </el-pagination>
    </div>
</template>

<script>
    import {
        hourCountReport
    } from '@/api/deviceController'
    export default {
        data() {
            return {
                tableData: [],
                fullTimeColumnList:[
                    "0","1","2","3","4",
                    "5","6","7","8","9",
                    "10","11","12","13",
                    "14","15","16","17",
                    "18","19","20","21",
                    "22","23"
                ],
                loading: false,
                total: 0,
            }
        },
        props: {
            searchForm: {
                type: Object,
                default: () => ({})
            }
        },
        methods: {
            getHourCountReport(data) {
                this.loading = true
                hourCountReport(data).then(res => {
                    if (res.code == 200) {
                        this.tableData = res.data
                        this.total = res.count
                    }
                    this.loading = false
                })
            },
            //pageSize 改变时会触发
            handleSizeChange(val) {
                this.searchForm.limit = val
                this.getHourCountReport(this.searchForm)
            },
            //currentPage 改变时会触发
            handleCurrentChange(val) {
                this.searchForm.page = val
                this.getHourCountReport(this.searchForm)
            },
        }
    }
</script>

<style lang="less" scoped>
    .tableList {
        code {
            font-family: sans-serif;
        }
    }
</style>